import { Component } from '@angular/core';
import { NavController, NavParams, LoadingController } from 'ionic-angular';
import { Storage } from '@ionic/storage';

import { Behavior } from '../../model/fans/behavior.model';
import { FanService } from '../../providers/fan';

@Component({
	selector: 'page-credits',
	templateUrl: 'credits.html',
	providers: [FanService]
})
export class CreditsPage {

	behaviors: Behavior[];
	integral: any;

	test: number = 0;
	constructor(
		private navCtrl: NavController,
		private params: NavParams,
		private storage: Storage,
		private loadingCtrl: LoadingController,
		private fanService: FanService
	) { };

	ionViewDidLoad() {
		this.integral = this.params.get('integral');
		let loading = this.loadingCtrl.create({
			spinner: 'circles'
		});
		this.storage.get('openid').then(v => {
			this.fanService.getBehavior(v).then(result => {
				this.behaviors = result;
				loading.dismiss();
			})
		})
	};

	setType(type) {
		return type === 1 ? 'danger' : 'secondary';
	};
}
